<%--
    Document   : AProduct
    Created on : Dec 2, 2013, 5:40:47 PM
    Author     : NamDH
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">



<html lang="en">
    <head>
        <c:if test="${empty sessionScope.ACCOUNT}">
            <c:redirect url="../login.jsp"/>
        </c:if>
        <c:if test="${sessionScope.ACCOUNT.role.roleID == 3}">
            <c:redirect url="../home.jsp"/>
        </c:if>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <title>PRTS - Admin Page</title>

        <!-- Bootstrap core CSS -->
        <link href="css/bootstrap.css" rel="stylesheet">

        <!-- Add custom CSS here -->
        <link href="css/sb-admin.css" rel="stylesheet">
        <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
        <!-- Page Specific CSS -->
        <link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.4.3.min.css">
        <link type="text/css" href="../css/table.css" rel="stylesheet">
        <script type="text/javascript">

            $('#txtSearch').keypress(function(e) {
                if(e.which == 13) {
                    jQuery(this).blur();
                    jQuery('#btAction').focus().click();
                }
            });
        </script>

    </head>

    <body>

        <div id="wrapper">

            <!-- Sidebar -->
            <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <div id ="logo" style="float:left; padding:3px">
                        <a href="../home.jsp">
                            <img style="height: 80px" src="../Images/PRTS.png"/>
                        </a>
                    </div>

                    <div  style="color:white; font-size: 3em;margin: 20px 0 0 70px; float:left;">
                        <span>Admin Page</span>
                    </div>

                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse navbar-ex1-collapse">

                    <ul class="nav navbar-nav side-nav">
                        <li><a href="../home.jsp"><i class="fa fa-home"></i> Home page</a></li>
                        <li ><a href="Admin.jsp"><i class="fa fa-dashboard"></i> Dashboard</a></li>
                        <li><a href="../AdminController?btAction=loadUser"><i class="fa fa-users"></i> Users</a></li>
                        <li  class="active"><a href="../AdminController?btAction=loadProduct"><i class="fa fa-tags"></i> Products</a></li>
                        <li><a href="TimeInterval.jsp"><i class="fa fa-clock-o"></i> Edit time interval</a></li>
                    </ul>

                    <ul class="nav navbar-nav navbar-right navbar-user">


                        <li id="dropdown-account" class="dropdown user-dropdown" style="max-height: 85px">
                            <a href="#" id="username-outer" class="dropdown-toggle" data-toggle="dropdown"> ${sessionScope.ACCOUNT.emailAddress} <b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                <li><a href="../home.jsp"><i class="fa fa-home"> </i> Home page</a></li>
                                <li><a href="../HomeController?btAction=logout"><i class="fa fa-power-off"></i> Log Out</a></li>
                            </ul>
                        </li>
                    </ul>
                </div><!-- /.navbar-collapse -->
            </nav>

            <div id="page-wrapper">

                <div class="row">
                    <div class="col-lg-12">
                        <h1>Products </h1>
                        <ol class="breadcrumb">
                            <li class="active"><a href="Admin.jsp"><i class="fa fa-dashboard"></i> Dashboard</a></li>
                            <li class="active"><i class="fa fa-dollar"></i> Products</li>
                        </ol>
                        <div class="alert alert-success alert-dismissable">
                            <form class="form-search" action="../AdminController?btAction=search">
                                <input id="txtSearch" name="txtSearch" type="text" class="input-medium search-query" placeholder="Search..." title="Search by account's email or full name..." >
                                <button type="submit" style="display: none" id="btAction" name="btAction" value="searchProduct">Search</button>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="table-responsive">
                    <c:set var="products" value="${sessionScope.TRACKEDPRODUCTS}"/>
                    <c:if test="${not empty products}">
                        <table class="table table-hover table-striped tablesorter table-autofilter table-autopage:10 table-stripeclass:alternate table-page-number:t1page table-page-count:t1pages table-filtered-rowcount:t1filtercount table-rowcount:t1allcount">
                            <thead>
                                <tr>
                                    <th></th>
                                    <th>Product name  <i class="fa fa-sort"></i></th>
                                    <th>Tracked by</th>
                                    <th>Date</th>
                                    <th></th>
                                </tr>
                            </thead>
                            <tbody>
                                <c:forEach var="product" items="${products}">
                                    <tr>
                                        <td></td>
                                        <td>${product.productName}</td>
                                        <td>${product.account.emailAddress}</td>
                                        <td>${product.trackedDate}</td>
                                        <td></td>
                                    </tr>
                                </c:forEach>
                            </tbody>
                            <tfoot>
                                <tr>
                                    <td align="left" class="table-page:first"
                                        style="cursor: pointer;"><img src="../Images/first.png" width="20" height="20"/></td>
                                    <td align="left" class="table-page:previous"
                                        style="cursor: pointer;"><img src="../Images/previous.png" width="20" height="20"/></td>
                                    <td style="text-align: center;">Page <span
                                            id="t1page"></span>&nbsp;of <span id="t1pages"></span>
                                    </td>
                                    <td align="right" class="table-page:next"
                                        style="cursor: pointer;"><img src="../Images/next.png" width="20" height="20"/></td>
                                    <td align="right" class="table-page:last" style="cursor: pointer;"><img src="../Images/last.png" width="20" height="20"/></td>
                                </tr>
                            </tfoot>
                        </table>
                    </c:if>

                    <c:set var="searchproducts" value="${sessionScope.SEARCHTRACKEDPRODUCTS}"/>
                    <c:if test="${not empty searchproducts}">
                     <table class="table table-hover table-striped tablesorter table-autofilter table-autopage:10 table-stripeclass:alternate table-page-number:t1page table-page-count:t1pages table-filtered-rowcount:t1filtercount table-rowcount:t1allcount">
                            <thead>
                                <tr>
                                    <th></th>
                                    <th>Product name  <i class="fa fa-sort"></i></th>
                                    <th>Tracked by</th>
                                    <th>Date</th>
                                    <th></th>

                                </tr>

                            </thead>
                            <tbody>
                                <c:forEach var="product" items="${searchproducts}">
                                    <tr>
                                        <td></td>
                                        <td>${product.productName}</td>
                                        <td>${product.account.emailAddress}</td>
                                        <td>${product.trackedDate}</td>
                                        <td></td>
                                    </tr>
                                </c:forEach>
                            </tbody>
                            <tfoot>
                                <tr>
                                    <td align="left" class="table-page:first"
                                        style="cursor: pointer;"><img src="../Images/first.png" width="20" height="20"/></td>
                                    <td align="left" class="table-page:previous"
                                        style="cursor: pointer;"><img src="../Images/previous.png" width="20" height="20"/></td>
                                    <td style="text-align: left;">Page <span
                                            id="t1page"></span>&nbsp;of <span id="t1pages"></span>
                                    </td>
                                    <td align="right" class="table-page:next"
                                        style="cursor: pointer;"><img src="../Images/next.png" width="20" height="20"/></td>
                                    <td align="right" class="table-page:last" style="cursor: pointer;"><img src="../Images/last.png" width="20" height="20"/></td>
                                </tr>
                            </tfoot>
                        </table>
                    </c:if>
                    <c:if test="${empty products && empty searchproducts}">
                        <h3 style="color:red">Can not find anything!</h3>
                    </c:if>
                </div>



            </div><!-- /#page-wrapper -->

        </div><!-- /#wrapper -->

        <!-- JavaScript -->
        <script src="js/jquery-1.10.2.js"></script>
        <script src="js/bootstrap.js"></script>

        <!-- Page Specific Plugins -->
        <script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
        <script src="http://cdn.oesmith.co.uk/morris-0.4.3.min.js"></script>
        <script src="js/morris/chart-data-morris.js"></script>
        <script src="js/tablesorter/jquery.tablesorter.js"></script>
        <script src="js/tablesorter/tables.js"></script>
        <script src="../js/table.js" type="text/javascript"></script>

    </body>
</html>

